<?php
    require_once("SmartyReady.php");
    require_once("usuario.php");
    require_once("mp3.php");
    require_once("playlists.php");
    // preparem l'smarty
    $sm = new SmartyReady();
    $sm->muntarTemplates();
    // preparem la sessio
    session_start();
  
    if (!empty($_SESSION['username'])) {
        $sm->assign('banner','bannerUser.tpl');
        $sm->assign('usuari',$_SESSION['username']);
        $sm->assign('pathAvatar',$_SESSION['avatar']);
        if (empty($_GET['idsong'])) {
            $sm->assign('cuerpo','linksong.tpl');
        }
        else  {
            $sm->assign('cuerpo','buit.tpl');
            $idsong = $_GET['idsong'];
            $idpl = $_SESSION['idplaylist'];
            $objPL = new Playlists($idpl);
            $objPL->add_song($idsong);
            ?><meta http-equiv="Refresh" content="0;url=./linkSongIPlaylist.php"><?php
        }
    }
    else {
        // T'has colat a la pagina XXX sense estar logejat
        $sm->assign("banner","login.tpl");
        $sm->assign('resultatLogin','');
        $sm->assign('cuerpo','buit.tpl');
        ?><meta http-equiv="Refresh" content="0;url=./index.php"><?php
    }
    $sm->display("E:/wamp/www/JediMusic/Smarty/templates/base.tpl");
?>
